package com.auqaoasis.model.field;

import com.auqaoasis.exception.ParseException;

import java.io.DataInputStream;
import java.io.IOException;

/**
 * @Author Auqaoasis
 * @Date 2022/3/29 - 21:28
 * @Description: 字段类型枚举
 */
public enum FieldType implements IFieldType {
    INT() {
        @Override
        public int getSizeInByte() {
            return 4;
        }

        @Override
        public Field parse(DataInputStream dis) {
            try {
                return new IntField(dis.readInt());
            } catch (IOException e) {
                throw new ParseException("parse field failed", e);
            }
        }
    },
    LONG() {
        @Override
        public int getSizeInByte() {
            return 8;
        }

        @Override
        public Field parse(DataInputStream dis) {
            try {
                return new LongField(dis.readLong());
            } catch (IOException e) {
                throw new ParseException("parse field failed", e);
            }
        }
    };
}
